// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Components/StaticMeshComponent.h"
#include "DynamicTreePartBase.generated.h"

/**
 * 
 */
class ADynamicTreeBase;

UCLASS()
class ISALONG2_API UDynamicTreePartBase : public UStaticMeshComponent
{
	GENERATED_BODY()

public:
	UDynamicTreePartBase();
	
private:
	// the life value of the connection node
	float _lifeValue = 1;

	// the owner actor of this component
	ADynamicTreeBase* _owner;

protected:
	// the up part or the down part of the actor of this trunk
	UDynamicTreePartBase* _upPart=nullptr;
	UDynamicTreePartBase* _downPart=nullptr;

public:
	// set the up part
	void SetUpPart(UDynamicTreePartBase* upPart);

	// set the below part
	void SetDownPart(UDynamicTreePartBase* downPart);

	// check for the hurt node and decide whether break or not
	void NodeHurtCheck(FVector hitLocation,int hurtType,float hurtValue);

	// set the actor which is the owner of this scene component
	void SetPartOwner(ADynamicTreeBase* owner);

	// unweld all childs
	void UnWeldAllChilds();

	void WeldAllChilds();

	// return the width of this part
	float GetWidth();

	// return the height of this part
	float GetHeight();

	// return the depth of this part
	float GetDepth();

	// call this function to alignment the tree parts autoily
	void SnapUp();
};
